<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P197 【例8-4】demo04.html</title>
</head>

<body>
    <form id="register" action="index.php" method="post">
        <label>用户名：<input id="user" type="index.php" method="post"></label>
        <input type="submit" value="提交"><input type="reset" value="重置">
    </form>
    <script>
        var regist = document.getElementById('register');
        var user = document.getElementById('user');
        regist.onsubmit = function (event) {
            var event = event || window.event;
            console.log(event.type);
            return user.value ? true : false;
        };
        regist.onreset = function (event) {
            var event = event || window.event;
            console.log(event.type);
            return confirm('请确认是否要重置信息，重置后表单填写的内容将全部清空');
        };
    </script>
    <a href="../首页/page08.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>